package edu.gym4all.service.enums;

import java.util.HashMap;
import java.util.Map;

import android.os.Parcel;
import android.os.Parcelable;

public enum TrainingTag implements Parcelable {

	EMPTY("empty"),

	A("A"),

	B("B"),

	C("C"),

	D("D"),

	E("E"),

	F("F"),

	FULL("FULL");

	private static Map<String, TrainingTag> trainingTagName;

	private String name;

	TrainingTag(String name) {
		this.name = name;
	}

	public String getName() {
		return this.name;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(this.ordinal());
	}

	public static final Creator<TrainingTag> CREATOR = new Creator<TrainingTag>() {
		@Override
		public TrainingTag createFromParcel(final Parcel source) {
			return TrainingTag.values()[source.readInt()];
		}

		@Override
		public TrainingTag[] newArray(final int size) {
			return new TrainingTag[size];
		}
	};

	public static Map<String, TrainingTag> loadTrainingTags() {
		trainingTagName = new HashMap<String, TrainingTag>();
		trainingTagName.put(A.getName(), A);
		trainingTagName.put(B.getName(), B);
		trainingTagName.put(C.getName(), C);
		trainingTagName.put(D.getName(), D);
		trainingTagName.put(E.getName(), E);
		trainingTagName.put(F.getName(), F);
		return trainingTagName;
	}

	public static TrainingTag getTrainingTag(String name) {
		Map<String, TrainingTag> map = TrainingTag.loadTrainingTags();
		return map.get(name);
	}
}